Coherence Configuration Enhancements - Part 1 - Injectables

Post on 12-Nov-2014

556 views 1 download

Tags:

description

Watch on YouTube: http://www.youtube.com/watch?v=muCC90UMSWY

Transcript of Coherence Configuration Enhancements - Part 1 - Injectables

<Insert Picture Here>

Coherence 12.1.2 Configuration EnhancementsPart 1: @InjectablesBrian OliverSenior Consulting Member of StaffCloud Application Foundation - Oracle Coherence

Oracle Fusion Middleware 12c Cloud Application Foundation

Coherence 12.1.2

2 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

The following is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

The Agenda…

4 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Coherence 12.1.2 ConfigurationEnhancements…• The Background…

– Everything’s changed… but nothing has changed…

• The Simple Improvements– Introducing @Injectable’s

• Summary

The Objectives…

6 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

The Objectives

• Improve Integration with Third-Party Frameworks– Containers (WLS, GlassFish, et al)– Injection Frameworks (CDI, Spring, Guice et al)– Permit Third-Party & Open Source Development– Allow Independent “plug-in” Development for Coherence Servers

• Allow Extension of Coherence– Add new custom features to Coherence

• Provide Complete* non-Xml Programmatic Configuration

7 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

What’s different?

• Nothing… and everything!

• Internally refactored…– Adopted a new internal Runtime Configuration Model– New Configuration Processing Model… that can be customized

and extended!– Removed dependency on XML

• Existing configurations should work without change

The Simple Improvements…

9 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style Cache Store Configuration<cache-config xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="" xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">

<caching-scheme-mapping> <cache-mapping> <cache-name>dist-*</cache-name> <scheme-name>distributed-scheme</scheme-name> </cache-mapping> </caching-scheme-mapping>

<caching-schemes> <distributed-scheme> <scheme-name>distributed-scheme</scheme-name> <service-name>DistributedCache</service-name>

<backing-map-scheme> <read-write-backing-map-scheme>

<cachestore-scheme> <class-scheme> <class-name>MyOldStyleCacheStore</class-name> </class-scheme> </cachestore-scheme> </read-write-backing-map-scheme> </backing-map-scheme>

<autostart>true</autostart> </distributed-scheme>

</caching-schemes></cache-config>

10 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style Cache Store Configuration

public class MyOldStyleCacheStore extends AbstractCacheStore{ @Override public Object load(Object o) { return null; // we're not going to support loading }

@Override public void store(Object oKey, Object oValue) { System.out.println("Storing Key: " + oKey + ", Value: " + oValue); }

@Override public void erase(Object oKey) { System.out.println("Erasing Key: " + oKey); }}

11 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style (with parameters). . . <caching-schemes> <distributed-scheme> <scheme-name>distributed-scheme</scheme-name> <service-name>DistributedCache</service-name>

<backing-map-scheme> <read-write-backing-map-scheme> <cachestore-scheme> <class-scheme> <class-name>MyOldStyleCacheStoreWithParameters</class-name> <init-params> <init-param> <param-type>string</param-type> <param-name>Cache Name</param-name> <param-value>{cache-name}</param-value> </init-param> </init-params> </class-scheme> </cachestore-scheme> </read-write-backing-map-scheme> </backing-map-scheme> <autostart>true</autostart> </distributed-scheme> </caching-schemes>. . .

12 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Old Style (with parameters)public class MyOldStyleCacheStoreWithParameters extends AbstractCacheStore{ private String m_CacheName;

public MyOldStyleCacheStoreWithParameters(String cacheName) { m_CacheName = cacheName; }

@Override public Object load(Object o) { return null; // we're not going to support loading }

@Override public void store(Object oKey, Object oValue) { System.out.println("Storing Key: " + oKey + ", Value: " + oValue + " for Cache: " + m_CacheName); }

@Override public void erase(Object oKey) { System.out.println("Erasing Key: " + oKey + " for Cache: " + m_CacheName); }}

Introducing @Injectable’s

14 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

New @Injectable Cache Storepublic class InjectableCacheStore extends AbstractCacheStore{ private String m_CacheName;

@Injectable public setCacheName(String cacheName) { m_CacheName = cacheName; }

@Override public Object load(Object o) { return null; // we're not going to support loading }

@Override public void store(Object oKey, Object oValue) { System.out.println("Storing Key: " + oKey + ", Value: " + oValue + " for Cache: " + m_CacheName); }

@Override public void erase(Object oKey) { System.out.println("Erasing Key: " + oKey + " for Cache: " + m_CacheName); }}

15 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

New @Injectable Cache Store<cache-config xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="" xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd">

<caching-scheme-mapping> <cache-mapping> <cache-name>dist-*</cache-name> <scheme-name>distributed-scheme</scheme-name> </cache-mapping> </caching-scheme-mapping>

<caching-schemes> <distributed-scheme> <scheme-name>distributed-scheme</scheme-name> <service-name>DistributedCache</service-name>

<backing-map-scheme> <read-write-backing-map-scheme> <cachestore-scheme> <class-scheme> <class-name>InjectableCacheStore</class-name> </class-scheme> </cachestore-scheme> </read-write-backing-map-scheme> </backing-map-scheme> <autostart>true</autostart> </distributed-scheme> </caching-schemes></cache-config>

16 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Introducing @Injectables

• Applicable when Coherence is provided with an Object…– It will attempt to initialize it with appropriate @Injectables– Based on the “context” of Object usage– Before it uses the Object for the first time

• eg: For <class-scheme> Coherence will try to inject…– cache-name, manager-context– ConfigurableCacheFactory, ClassLoader– Any other Named/Typed Resource from the Resource Registry

17 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Introducing @Injectables

• Javadoc defines what can be injected with @Injectable– Look in com.tangosol.coherence.config package

• @Injectable’s Property Resolution…– Automatically uses Camel-Case of Setter Method to find a property

• “setCacheName” method becomes “cache-name” property

– Or… optionally specify “exact name” of the property@Injectable(“cache-name”)

public void setSomeMethodName(String name)

{ …

}

18 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Introducing @Injectables

• Where does this apply?– ClassScheme’s aka: <class-scheme>– Instance’s aka: <instance>– … customized namespaces!

• Where not?– <partition-listener>

Summary

20 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Summary

• Coherence 12.1.2 introduces @Injectable annotation– Provides type-safe object injection– Automatically determines property names and types– Help reduces XML configuration requirement

21 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

Next Part?

• Using Objects from other frameworks– Native integration – Avoiding the use of statics

Join the Coherence Community

http://coherence.oracle.com

@OracleCoherence

/OracleCoherence

blogs.oracle.com/OracleCoherence

Group: Oracle Coherence Users

/OracleCoherence

coherence.oracle.com/display/CSIGCoherence Special Interest Group

23 Copyright © 2013, Oracle and/or its affiliates. All rights reserved.

The proceeding is intended to outline our general product direction. It is intended for information purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.

<Insert Picture Here>

Coherence 12.1.2 Configuration EnhancementsPart 1: @InjectablesBrian OliverSenior Consulting Member of StaffCloud Application Foundation - Oracle Coherence

Oracle Fusion Middleware 12c Cloud Application Foundation

Coherence 12.1.2