You are viewing a plain text version of this content. The canonical link for it is here.
Posted to imperius-dev@incubator.apache.org by Neeraj Joshi <jn...@us.ibm.com> on 2008/01/19 03:40:58 UTC

SPI , APIs etc

Hi Erik,
I share your concern about playing with classloaders.
With regards to your questions
SPI / API : The interfaces within the external package etc can be 
classified into SPI or API. Are you referring to documenting which is 
which and how to use them?
or you are thinking there are more places where we could add APIs/ SPIs ? 
(or we need to add more methods to the existing interfaces?)

XML schema for Expressions: I will give that a shot and will post it and 
we can iterate over it (or if you have something already please share it)

You had also talked about a Factory that would instantiate the SPL engine. 
I was thinking of a class with a static method which returns a singleton 
instance of
PolicyManager did you have anything more in mind?

Thanks
Neeraj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 
Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/18/2008 04:00 PM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: Eclipse Editor for SPL checked in






Neeraj,

It uses the caller classloader. I don’t like playing with context
classloader and this fix, IMO, is temporary because it should be replaced 
by
a refactor in the parsing/compilation mechanism to pushdown the execution 
a
custom classloader.

Before more coding changes I would suggest specifying the user/spi API, in
particular factories, interfaces and the declaration model (XML) for 
custom
expressions/actions.

-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : vendredi 18 janvier 2008 20:58
À : imperius-dev@incubator.apache.org
Objet : RE: Eclipse Editor for SPL checked in

Hi Erik,
Thanks yet again, that fixed the issue.
I just have a question regarding the changes in the ACPLParserMap.
In the catch clause you are trying to load the class again using the 
current Thread's class loader.
Why isn't the current thread's class loader the default one? What 
classloader is used in the try block?

Thanks
Neeraj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 

Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/17/2008 05:33 PM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: Eclipse Editor for SPL checked in






You are right, same issue again. Patches added to JIRA.

For a fully understanding:

Eclipse run with claspath A:

Current thread context is classpath A-> no access

Plugin splcore has classpath B -> this can access classes in D
Plugin splcoreeditor has classpath C -> this can access classes in B and D
Plugin antlr has classpath D -> no access
Plugin javasplcore has classpath E -> this can access classes in B

The user project has the SPL files and the custom jar in its path.


When the Eclipse SPL Editor runs, it runs on classpath A, thus loading
classes from plugins or user projects wont work.

For this reason, when running the ANTLR parser you need to change the
context classloader with a custom URL classloader that's built upon the 
user
project dependencies and splcore classpath. The classpath C is set as 
parent
for the custom URL classloader to be able to resolve splcore classes when
running/compiling the policy.

-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : jeudi 17 janvier 2008 21:05Y
À : imperius-dev@incubator.apache.org
Objet : RE: Eclipse Editor for SPL checked in

Hey Eric,
Thanks for the fix. The antlr problem got resolved with that.
However, there is another classloader issue now related to the 
customexpressions. 
If you do Project -> Properties -> Policy / Add Custom jar -> Apply
A jar with custom expression classes gets added to the project classpath 
and ACPLParserMap is updated with the new expressions

When an expression defined in the jar is added to the policy in the editor 


the validation fails (symbol not defined). 
As the splcore is now a seperate bundle I think its a classloader issue is 


at play again.
Any ideas?

Neeraj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 


Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/17/2008 01:19 PM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: Eclipse Editor for SPL checked in






Neeraj,

Another way

-----Message d'origine-----
De : Erik Bengtson [mailto:erik@jpox.org] 
Envoyé : jeudi 17 janvier 2008 19:15
À : imperius-dev@incubator.apache.org
Objet : RE: Eclipse Editor for SPL checked in

Neeraj,

Fix attached to IMPERIUS-2. The problem was with the classloader used by
antlr, the current thread classloader, that does not have access to the
ASTWithLineNumber.


-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : jeudi 17 janvier 2008 15:24
À : imperius-dev@incubator.apache.org
Objet : Re: Eclipse Editor for SPL checked in

Hey Eric,
Actually I am having trouble with the original antlr plugin itself..I used 



the one found here http://antlreclipse.sourceforge.net/
Which plugin did you use? The way I found out that antlr libraries arn't 
getting imported is when you try to author a policy : no outline shows up 
in the outline view , no errors appear if you write invalid syntax and 
stuff like drop down list of anchor class properties doesn't appear...
Thanks
Neeraj

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 



Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/17/2008 02:10 AM
Please respond to
imperius-dev@incubator.apache.org


To
"Imperius" <im...@incubator.apache.org>
cc

Subject
Re: Eclipse Editor for SPL checked in






Neeraj,

This is necessary for development only. If you install the original antlr 
plugin, it should work.


--   BlackBerry® from Mobistar    ---

-----Original Message-----
From: Neeraj Joshi <jn...@us.ibm.com>

Date: Wed, 16 Jan 2008 17:43:19 
To:imperius-dev@incubator.apache.org
Subject: RE: Eclipse Editor for SPL checked in


Hey Eric,
That seemed to do the trick...but that implies that the user would have to 




follow similar steps to get the Editor operational (Generate a plugin from 




antlr.jar) 
Any ideas how to make the user's life easier?
Neeraj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others." 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/16/2008 03:24 PM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: Eclipse Editor for SPL checked in






Neeraj,

Create a Plugin from the antlr jar. In Eclipse there is a wizard called
"Plugin from existing jar archives".

Regards,

-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : mercredi 16 janvier 2008 21:04
À : imperius-dev@incubator.apache.org
Objet : RE: Eclipse Editor for SPL checked in

Hi Erik,
Thank you for the patches, this makes things much cleaner.

I am having some trouble with the new plugins basically the antlr 
libraries are not getting imported correctly.
When I do SPLEditor -> Run as -> Open Run dialog and validate plugins I 
see for the splcore bundle some errors like [Missing Constraint: Import 
Package: antlr]
for all of the Import packages within the Manifest.

I tried adding a Require-Bundle for org.antlr but that didn't seem to 
help...

Other error that I fixed was that within the spleditorcore and 
javasplextension plugin the Bundle-ClassPath had to be changed from the 
jar to  '.'

Did you encounter issues importing antlr? any suggestions on what I can 
try out?
Neeraj


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others." 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/15/2008 04:51 PM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: Eclipse Editor for SPL checked in






Hi,

Patches added to JIRA IMPERIUS-2, allows creating valid eclipse plugins, 
and
all jars are valid osgi bundles.

With this configuration, the user eclipse plugin installation instructions
would be:

Build projects with maven
Copy built jars to <ECLIPSE_DIR>/plugins
Install ANTLR eclipse plugin in <ECLIPSE_DIR>/plugins

Erik

-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : mardi 15 janvier 2008 8:13
À : imperius-dev@incubator.apache.org
Objet : Eclipse Editor for SPL checked in

Hi All,
I have checked in the editor code. I have also updated the website with 
instructions to build and use the editor. Let me know if you face any 
problems.
Thanks
Neeraj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others." 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~





















RE: SPI , APIs etc

Posted by Neeraj Joshi <jn...@us.ibm.com>.
Hi Erik,
You are correct that the DC and AC are both bound to the Rule provider. 
What I was thinking was the rule provider could also use this same 
descriptor to pick which DC and AC implementation to instantiate.
It could be that there may be more than 1 implementations of each and the 
rule provider chooses which ones to use based on the descriptor. 
Alternatively, we could have the Rule provider read a seperate descriptor 
to keep things simple
What do you think?
Neeraj
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 
Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/24/2008 01:49 PM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: SPI , APIs etc






Neeraj,

I understand the datacollector and actuator instances are bound to the
policy rule provider, why configure them?

Erik
-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : mardi 22 janvier 2008 17:42
À : imperius-dev@incubator.apache.org
Objet : RE: SPI , APIs etc

Hi All,
Here is the proposed SPL descriptor 

<?xml version="1.0" encoding="UTF-8"?>
<SPL xmlns="http://org.apache.imperius"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://org.apache.imperius SPLDescriptor.xsd">
        <SPLConfiguration>
                <SPLHome>.</SPLHome>
                <SPLPolicyRuleProvider>
org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider</
SPLPolicyRuleProvider>
                <SPLDataCollector>
org.apache.imperius.javaspl.JavaDataCollectorImpl</SPLDataCollector>
                <SPLActuator>org.apache.imperius.javaspl.JavaActuatorImpl
</SPLActuator>
                <logging>
                        <log-file>SPLLog.log</log-file>
                        <log-level>FINE</log-level>
                        <audit-file>SPLAudit.log</audit-file>
                </logging>
        </SPLConfiguration>
        <SPLExpressions>
                <SPLOperatorExpressionList>
                        <SPLOperatorExpression returnType="boolean" 
expressionType="Boolean">LogicalOr</SPLOperatorExpression>
                        <SPLOperatorExpression returnType="number" 
expressionType="Numeric">Addition</SPLOperatorExpression>
                </SPLOperatorExpressionList>
                <SPLActionExpressionList>
                        <SPLActionExpression>ReturnValues</
SPLActionExpression>
                </SPLActionExpressionList>
        </SPLExpressions>
 
</SPL>


And here is the schema 

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.apache.imperius"
xmlns="http://org.apache.imperius"
elementFormDefault="qualified">
<!--  Expression Classification  -->
  <xsd:simpleType name="expressionType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="Boolean"/>
     <xsd:enumeration value="Numeric"/>
     <xsd:enumeration value="String"/>
     <xsd:enumeration value="Collection"/>
     <xsd:enumeration value="DateTime"/>
   </xsd:restriction>
  </xsd:simpleType>
<!--  Data Type --> 
  <xsd:simpleType name="dataType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="boolean"/>
     <xsd:enumeration value="number"/>
     <xsd:enumeration value="byte"/>
     <xsd:enumeration value="short"/>
     <xsd:enumeration value="integer"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="float"/>
     <xsd:enumeration value="double"/>
     <xsd:enumeration value="string"/>
     <xsd:enumeration value="datetime"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="reference"/>
     <xsd:enumeration value="boolean[]"/>
     <xsd:enumeration value="number[]"/>
     <xsd:enumeration value="byte[]"/>
     <xsd:enumeration value="short[]"/>
     <xsd:enumeration value="integer[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="float[]"/>
     <xsd:enumeration value="double[]"/>
     <xsd:enumeration value="string[]"/>
     <xsd:enumeration value="datetime[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="reference[]"/>
   </xsd:restriction>
  </xsd:simpleType>
 
  <!--  Logging configuration -->
  <xsd:element name="log-file" type="xsd:anyURI"/>
  <xsd:element name="audit-file" type="xsd:anyURI"/>
 
  <xsd:element name="log-level">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="OFF"/>
        <xsd:enumeration value="SEVERE"/>
        <xsd:enumeration value="WARNING"/>
        <xsd:enumeration value="INFO"/>
        <xsd:enumeration value="FINE"/>
        <xsd:enumeration value="FINER"/>
        <xsd:enumeration value="FINEST"/>
        <xsd:enumeration value="ALL"/>
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>

  <xsd:element name="logging">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="log-file"/>
        <xsd:element ref="log-level"/>
        <xsd:element ref="audit-file"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
 
  <xsd:element name="SPL">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLConfiguration"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLExpressions"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLConfiguration">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="SPLHome"/>
            <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLPolicyRuleProvider"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLDataCollector"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLActuator"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="logging"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLExpressions">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" ref="SPLOperatorExpressionList"
/>
                <xsd:element maxOccurs="1" ref="SPLActionExpressionList"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLOperatorExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLActionExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpression">
    <xsd:complexType mixed="true">
      <xsd:attribute name="returnType" type="dataType" use="required"/>
      <xsd:attribute name="expressionType" type="expressionType" use=
"required"/>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpression" type="xsd:string"/>
  <xsd:element name="SPLPolicyRuleProvider" type="xsd:string"/>
  <xsd:element name="SPLDataCollector" type="xsd:string"/>
  <xsd:element name="SPLActuator" type="xsd:string"/>
  <xsd:element name="SPLHome" type="xsd:string" default="."/>

 
 
</xsd:schema>


Comments / Suggestions?

Neeraj

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 

Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/19/2008 06:10 AM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: SPI , APIs etc






>SPI / API : The interfaces within the external package etc can be 
>classified into SPI or API. Are you referring to documenting which is 
>which and how to use them?

+ Some consistent naming across the methods

>or you are thinking there are more places where we could add APIs/ SPIs ? 


>(or we need to add more methods to the existing interfaces?)

Add and drop methods/interfaces

>XML schema for Expressions: I will give that a shot and will post it and 
>we can iterate over it (or if you have something already please share it)

Go ahead.

>You had also talked about a Factory that would instantiate the SPL 
engine. 
>I was thinking of a class with a static method which returns a singleton 
>instance of
>PolicyManager did you have anything more in mind?

IMO a singleton is not a good pattern inside a framework and should be 
handled by users if they need this pattern.

Here is a rough proposal for API (MBeans should also be in the API, but 
not specified here):

Interface Policy{
String getName();
Boolean deploy(); //update=true
Boolean deploy(boolean update);
Boolean undeploy();
}

Interface PolicyManager{...}
Interface SPI.DataColletor{...}
Interface SPI.Actuator{...}
Interface SPI.PolicyRuleProvider
{
getDataCollector();
getActuator();
}
Interface SPI.PolicyEvaluator
{
Object evaluate(Map params);
}
Class JavaSPL.PolicyRuleProviderImpl implements PolicyRuleProvider

Class SPLCore.PolicyManagerImpl implements PolicyManager

Class SPLCore.ImperiusFactory
{
static PolicyManager newPolicyManager(Map properties);
}

Example 1 (Factory and Evaluator):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 2 (Custom Datastore):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...); //other properties e.g. datastore connection properties
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Custom Evaluator - Evaluate via RMI):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put("org.apache.imperius.spl.PolicyEvaluatorClass", 
"Custom.RMIPolicyEvaluatorImpl");
m.put(...); //other properties e.g. datastore connection properties and 
rmi server
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Deploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.newPolicy(name);
policy.deploy();

Example 4 (UnDeploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.getPolicy(name);
policy.undeploy();








RE: SPI , APIs etc

Posted by Erik Bengtson <er...@jpox.org>.
Neeraj,

I understand the datacollector and actuator instances are bound to the
policy rule provider, why configure them?

Erik
-----Message d'origine-----
De : Neeraj Joshi [mailto:jneeraj@us.ibm.com] 
Envoyé : mardi 22 janvier 2008 17:42
À : imperius-dev@incubator.apache.org
Objet : RE: SPI , APIs etc

Hi All,
Here is the proposed SPL descriptor 

<?xml version="1.0" encoding="UTF-8"?>
<SPL xmlns="http://org.apache.imperius"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://org.apache.imperius SPLDescriptor.xsd">
        <SPLConfiguration>
                <SPLHome>.</SPLHome>
                <SPLPolicyRuleProvider>
org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider</
SPLPolicyRuleProvider>
                <SPLDataCollector>
org.apache.imperius.javaspl.JavaDataCollectorImpl</SPLDataCollector>
                <SPLActuator>org.apache.imperius.javaspl.JavaActuatorImpl
</SPLActuator>
                <logging>
                        <log-file>SPLLog.log</log-file>
                        <log-level>FINE</log-level>
                        <audit-file>SPLAudit.log</audit-file>
                </logging>
        </SPLConfiguration>
        <SPLExpressions>
                <SPLOperatorExpressionList>
                        <SPLOperatorExpression returnType="boolean" 
expressionType="Boolean">LogicalOr</SPLOperatorExpression>
                        <SPLOperatorExpression returnType="number" 
expressionType="Numeric">Addition</SPLOperatorExpression>
                </SPLOperatorExpressionList>
                <SPLActionExpressionList>
                        <SPLActionExpression>ReturnValues</
SPLActionExpression>
                </SPLActionExpressionList>
        </SPLExpressions>
 
</SPL>


And here is the schema 

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.apache.imperius"
xmlns="http://org.apache.imperius"
elementFormDefault="qualified">
<!--  Expression Classification  -->
  <xsd:simpleType name="expressionType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="Boolean"/>
     <xsd:enumeration value="Numeric"/>
     <xsd:enumeration value="String"/>
     <xsd:enumeration value="Collection"/>
     <xsd:enumeration value="DateTime"/>
   </xsd:restriction>
  </xsd:simpleType>
<!--  Data Type --> 
  <xsd:simpleType name="dataType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="boolean"/>
     <xsd:enumeration value="number"/>
     <xsd:enumeration value="byte"/>
     <xsd:enumeration value="short"/>
     <xsd:enumeration value="integer"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="float"/>
     <xsd:enumeration value="double"/>
     <xsd:enumeration value="string"/>
     <xsd:enumeration value="datetime"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="reference"/>
     <xsd:enumeration value="boolean[]"/>
     <xsd:enumeration value="number[]"/>
     <xsd:enumeration value="byte[]"/>
     <xsd:enumeration value="short[]"/>
     <xsd:enumeration value="integer[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="float[]"/>
     <xsd:enumeration value="double[]"/>
     <xsd:enumeration value="string[]"/>
     <xsd:enumeration value="datetime[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="reference[]"/>
   </xsd:restriction>
  </xsd:simpleType>
 
  <!--  Logging configuration -->
  <xsd:element name="log-file" type="xsd:anyURI"/>
  <xsd:element name="audit-file" type="xsd:anyURI"/>
 
  <xsd:element name="log-level">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="OFF"/>
        <xsd:enumeration value="SEVERE"/>
        <xsd:enumeration value="WARNING"/>
        <xsd:enumeration value="INFO"/>
        <xsd:enumeration value="FINE"/>
        <xsd:enumeration value="FINER"/>
        <xsd:enumeration value="FINEST"/>
        <xsd:enumeration value="ALL"/>
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>

  <xsd:element name="logging">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="log-file"/>
        <xsd:element ref="log-level"/>
        <xsd:element ref="audit-file"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
 
  <xsd:element name="SPL">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLConfiguration"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLExpressions"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLConfiguration">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="SPLHome"/>
            <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLPolicyRuleProvider"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLDataCollector"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLActuator"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="logging"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLExpressions">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" ref="SPLOperatorExpressionList"
/>
                <xsd:element maxOccurs="1" ref="SPLActionExpressionList"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLOperatorExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLActionExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpression">
    <xsd:complexType mixed="true">
      <xsd:attribute name="returnType" type="dataType" use="required"/>
      <xsd:attribute name="expressionType" type="expressionType" use=
"required"/>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpression" type="xsd:string"/>
  <xsd:element name="SPLPolicyRuleProvider" type="xsd:string"/>
  <xsd:element name="SPLDataCollector" type="xsd:string"/>
  <xsd:element name="SPLActuator" type="xsd:string"/>
  <xsd:element name="SPLHome" type="xsd:string" default="."/>

 
 
</xsd:schema>


Comments / Suggestions?

Neeraj

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 
Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/19/2008 06:10 AM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: SPI , APIs etc






>SPI / API : The interfaces within the external package etc can be 
>classified into SPI or API. Are you referring to documenting which is 
>which and how to use them?

+ Some consistent naming across the methods

>or you are thinking there are more places where we could add APIs/ SPIs ? 

>(or we need to add more methods to the existing interfaces?)

Add and drop methods/interfaces

>XML schema for Expressions: I will give that a shot and will post it and 
>we can iterate over it (or if you have something already please share it)

Go ahead.

>You had also talked about a Factory that would instantiate the SPL 
engine. 
>I was thinking of a class with a static method which returns a singleton 
>instance of
>PolicyManager did you have anything more in mind?

IMO a singleton is not a good pattern inside a framework and should be 
handled by users if they need this pattern.

Here is a rough proposal for API (MBeans should also be in the API, but 
not specified here):

Interface Policy{
String getName();
Boolean deploy(); //update=true
Boolean deploy(boolean update);
Boolean undeploy();
}

Interface PolicyManager{...}
Interface SPI.DataColletor{...}
Interface SPI.Actuator{...}
Interface SPI.PolicyRuleProvider
{
getDataCollector();
getActuator();
}
Interface SPI.PolicyEvaluator
{
Object evaluate(Map params);
}
Class JavaSPL.PolicyRuleProviderImpl implements PolicyRuleProvider

Class SPLCore.PolicyManagerImpl implements PolicyManager

Class SPLCore.ImperiusFactory
{
static PolicyManager newPolicyManager(Map properties);
}

Example 1 (Factory and Evaluator):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 2 (Custom Datastore):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...); //other properties e.g. datastore connection properties
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Custom Evaluator - Evaluate via RMI):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put("org.apache.imperius.spl.PolicyEvaluatorClass", 
"Custom.RMIPolicyEvaluatorImpl");
m.put(...); //other properties e.g. datastore connection properties and 
rmi server
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Deploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.newPolicy(name);
policy.deploy();

Example 4 (UnDeploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.getPolicy(name);
policy.undeploy();







RE: SPI , APIs etc

Posted by Neeraj Joshi <jn...@us.ibm.com>.
Hi All,
Here is the proposed SPL descriptor XML

<?xml version="1.0" encoding="UTF-8"?>
<SPL xmlns="http://org.apache.imperius"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://org.apache.imperius SPLDescriptor.xsd">
        <SPLConfiguration>
                <SPLHome>.</SPLHome>
                <SPLPolicyRuleProvider>
org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider</
SPLPolicyRuleProvider>
                <SPLDataCollector>
org.apache.imperius.javaspl.JavaDataCollectorImpl</SPLDataCollector>
                <SPLActuator>org.apache.imperius.javaspl.JavaActuatorImpl
</SPLActuator>
                <logging>
                        <log-file>SPLLog.log</log-file>
                        <log-level>FINE</log-level>
                        <audit-file>SPLAudit.log</audit-file>
                </logging>
        </SPLConfiguration>
        <SPLExpressions>
                <SPLOperatorExpressionList>
                        <SPLOperatorExpression returnType="boolean" 
expressionType="Boolean">LogicalOr</SPLOperatorExpression>
                        <SPLOperatorExpression returnType="number" 
expressionType="Numeric">Addition</SPLOperatorExpression>
                </SPLOperatorExpressionList>
                <SPLActionExpressionList>
                        <SPLActionExpression>ReturnValues</
SPLActionExpression>
                </SPLActionExpressionList>
        </SPLExpressions>
 
</SPL>


And here is the schema 

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://org.apache.imperius"
xmlns="http://org.apache.imperius"
elementFormDefault="qualified">
<!--  Expression Classification  -->
  <xsd:simpleType name="expressionType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="Boolean"/>
     <xsd:enumeration value="Numeric"/>
     <xsd:enumeration value="String"/>
     <xsd:enumeration value="Collection"/>
     <xsd:enumeration value="DateTime"/>
   </xsd:restriction>
  </xsd:simpleType>
<!--  Data Type --> 
  <xsd:simpleType name="dataType">
   <xsd:restriction base="xsd:string">
     <xsd:enumeration value="boolean"/>
     <xsd:enumeration value="number"/>
     <xsd:enumeration value="byte"/>
     <xsd:enumeration value="short"/>
     <xsd:enumeration value="integer"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="float"/>
     <xsd:enumeration value="double"/>
     <xsd:enumeration value="string"/>
     <xsd:enumeration value="datetime"/>
     <xsd:enumeration value="long"/>
     <xsd:enumeration value="reference"/>
     <xsd:enumeration value="boolean[]"/>
     <xsd:enumeration value="number[]"/>
     <xsd:enumeration value="byte[]"/>
     <xsd:enumeration value="short[]"/>
     <xsd:enumeration value="integer[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="float[]"/>
     <xsd:enumeration value="double[]"/>
     <xsd:enumeration value="string[]"/>
     <xsd:enumeration value="datetime[]"/>
     <xsd:enumeration value="long[]"/>
     <xsd:enumeration value="reference[]"/>
   </xsd:restriction>
  </xsd:simpleType>
 
  <!--  Logging configuration -->
  <xsd:element name="log-file" type="xsd:anyURI"/>
  <xsd:element name="audit-file" type="xsd:anyURI"/>
 
  <xsd:element name="log-level">
    <xsd:simpleType>
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="OFF"/>
        <xsd:enumeration value="SEVERE"/>
        <xsd:enumeration value="WARNING"/>
        <xsd:enumeration value="INFO"/>
        <xsd:enumeration value="FINE"/>
        <xsd:enumeration value="FINER"/>
        <xsd:enumeration value="FINEST"/>
        <xsd:enumeration value="ALL"/>
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>

  <xsd:element name="logging">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="log-file"/>
        <xsd:element ref="log-level"/>
        <xsd:element ref="audit-file"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
 
  <xsd:element name="SPL">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLConfiguration"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLExpressions"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLConfiguration">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="SPLHome"/>
            <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLPolicyRuleProvider"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLDataCollector"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref=
"SPLActuator"/>
                <xsd:element maxOccurs="1" minOccurs="1"  ref="logging"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLExpressions">
        <xsd:complexType>
           <xsd:sequence>
                <xsd:element maxOccurs="1" ref="SPLOperatorExpressionList"
/>
                <xsd:element maxOccurs="1" ref="SPLActionExpressionList"/>
           </xsd:sequence>
        </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLOperatorExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpressionList">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element maxOccurs="unbounded" ref="SPLActionExpression"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLOperatorExpression">
    <xsd:complexType mixed="true">
      <xsd:attribute name="returnType" type="dataType" use="required"/>
      <xsd:attribute name="expressionType" type="expressionType" use=
"required"/>
    </xsd:complexType>
  </xsd:element>
  <xsd:element name="SPLActionExpression" type="xsd:string"/>
  <xsd:element name="SPLPolicyRuleProvider" type="xsd:string"/>
  <xsd:element name="SPLDataCollector" type="xsd:string"/>
  <xsd:element name="SPLActuator" type="xsd:string"/>
  <xsd:element name="SPLHome" type="xsd:string" default="."/>

 
 
</xsd:schema>


Comments / Suggestions?

Neeraj

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Those are my principles. If you don't like them I have others. -- Groucho 
Marx" 

http://incubator.apache.org/imperius
 
Neeraj Joshi
Autonomic Computing Policy Development
Tivoli, IBM

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



"Erik Bengtson" <er...@jpox.org> 
01/19/2008 06:10 AM
Please respond to
imperius-dev@incubator.apache.org


To
<im...@incubator.apache.org>
cc

Subject
RE: SPI , APIs etc






>SPI / API : The interfaces within the external package etc can be 
>classified into SPI or API. Are you referring to documenting which is 
>which and how to use them?

+ Some consistent naming across the methods

>or you are thinking there are more places where we could add APIs/ SPIs ? 

>(or we need to add more methods to the existing interfaces?)

Add and drop methods/interfaces

>XML schema for Expressions: I will give that a shot and will post it and 
>we can iterate over it (or if you have something already please share it)

Go ahead.

>You had also talked about a Factory that would instantiate the SPL 
engine. 
>I was thinking of a class with a static method which returns a singleton 
>instance of
>PolicyManager did you have anything more in mind?

IMO a singleton is not a good pattern inside a framework and should be 
handled by users if they need this pattern.

Here is a rough proposal for API (MBeans should also be in the API, but 
not specified here):

Interface Policy{
String getName();
Boolean deploy(); //update=true
Boolean deploy(boolean update);
Boolean undeploy();
}

Interface PolicyManager{...}
Interface SPI.DataColletor{...}
Interface SPI.Actuator{...}
Interface SPI.PolicyRuleProvider
{
getDataCollector();
getActuator();
}
Interface SPI.PolicyEvaluator
{
Object evaluate(Map params);
}
Class JavaSPL.PolicyRuleProviderImpl implements PolicyRuleProvider

Class SPLCore.PolicyManagerImpl implements PolicyManager

Class SPLCore.ImperiusFactory
{
static PolicyManager newPolicyManager(Map properties);
}

Example 1 (Factory and Evaluator):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 2 (Custom Datastore):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...); //other properties e.g. datastore connection properties
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Custom Evaluator - Evaluate via RMI):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put("org.apache.imperius.spl.PolicyEvaluatorClass", 
"Custom.RMIPolicyEvaluatorImpl");
m.put(...); //other properties e.g. datastore connection properties and 
rmi server
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Deploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.newPolicy(name);
policy.deploy();

Example 4 (UnDeploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", 
"JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", 
"Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.getPolicy(name);
policy.undeploy();





RE: SPI , APIs etc

Posted by Erik Bengtson <er...@jpox.org>.
>SPI / API : The interfaces within the external package etc can be 
>classified into SPI or API. Are you referring to documenting which is 
>which and how to use them?

+ Some consistent naming across the methods

>or you are thinking there are more places where we could add APIs/ SPIs ? 
>(or we need to add more methods to the existing interfaces?)

Add and drop methods/interfaces

>XML schema for Expressions: I will give that a shot and will post it and 
>we can iterate over it (or if you have something already please share it)

Go ahead.

>You had also talked about a Factory that would instantiate the SPL engine. 
>I was thinking of a class with a static method which returns a singleton 
>instance of
>PolicyManager did you have anything more in mind?

IMO a singleton is not a good pattern inside a framework and should be handled by users if they need this pattern.

Here is a rough proposal for API (MBeans should also be in the API, but not specified here):

Interface Policy{
String getName();
Boolean deploy(); //update=true
Boolean deploy(boolean update);
Boolean undeploy();
}

Interface PolicyManager{...}
Interface SPI.DataColletor{...}
Interface SPI.Actuator{...}
Interface SPI.PolicyRuleProvider
{
getDataCollector();
getActuator();
}
Interface SPI.PolicyEvaluator
{
Object evaluate(Map params);
}
Class JavaSPL.PolicyRuleProviderImpl implements PolicyRuleProvider

Class SPLCore.PolicyManagerImpl implements PolicyManager

Class SPLCore.ImperiusFactory
{
static PolicyManager newPolicyManager(Map properties);
}

Example 1 (Factory and Evaluator):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", "JavaSPL.PolicyRuleProviderImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 2 (Custom Datastore):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", "JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", "Custom.RDBMSDatastoreImpl");
m.put(...); //other properties e.g. datastore connection properties
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Custom Evaluator - Evaluate via RMI):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", "JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", "Custom.RDBMSDatastoreImpl");
m.put("org.apache.imperius.spl.PolicyEvaluatorClass", "Custom.RMIPolicyEvaluatorImpl");
m.put(...); //other properties e.g. datastore connection properties and rmi server
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
PolicyEvaluator eval = pm.newPolicyEvaluator(name);
Map result = eval.evaluate(parameters);

Example 3 (Deploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", "JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", "Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.newPolicy(name);
policy.deploy();

Example 4 (UnDeploy Policy):
Map m = ...
m.put("org.apache.imperius.spl.PolicyRuleProviderClass", "JavaSPL.PolicyRuleProviderImpl");
m.put("org.apache.imperius.spl.DatastoreClass", "Custom.RDBMSDatastoreImpl");
m.put(...);
PolicyManager pm = ImperiusFactory.newPolicyManager(m);
Policy policy = pm.getPolicy(name);
policy.undeploy();